<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" import="java.util.Enumeration,java.net.URLEncoder" %>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib  uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>   
<%@ taglib  uri="http://jsptags.com/tags/navigation/pager" prefix="pg"%> 
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	
	String paramsString = "";
	Enumeration paramNames = (Enumeration)request.getParameterNames();
	while(paramNames.hasMoreElements()){
		String name = (String)paramNames.nextElement();
		if(name.indexOf("pager.")!=-1){
			continue;
		}
		
		String[] values = request.getParameterValues(name);
		if(values.length==1){
			paramsString = paramsString + "&" + name + "=" + URLEncoder.encode(values[0],"utf-8");
		}else if(values.length>1){
			for(String value : values){
				paramsString = paramsString + "&" + name + "=" + URLEncoder.encode(value,"utf-8");
			}
		}
	}
	request.setAttribute("paramsString",paramsString);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>this is the test pagination jsp</title>
	<style type="text/css">
	  .goodsDiv{
	         positon:relative;
	         width:100px;
	         height:30px;
	         border:1px;
	      }	         
	</style>
			<link href="common/style/Default.css"
			type="text/css" rel="stylesheet" />
  </head>
  <body>
        <s:iterator value="pageList" id="goods" status="s">
            <div class="goodsDiv"><s:property value="#goods.goodName"/></div>
        </s:iterator>
        <div class="digg">
        <pg:pager items="${pager.totalPageCount}" url="${pageUrl}" maxPageItems="1" export="currentPageNumber=pageNumber"  >   
            <pg:index>   
               <pg:first><a href="${pageUrl}${paramsString}"><nobr>&nbsp;[首页]</nobr></a></pg:first>   
               <pg:prev><a href="${pageUrl}${paramsString}">前一页</a></pg:prev>   
               <pg:pages>   
                     <c:choose>   
                        <c:when test="${currentPageNumber eq pageNumber}">     
                           <font color="red">${pageNumber}</font>   
                        </c:when>     
                        <c:otherwise>     
                           <a href="${pageUrl}${paramsString}">${pageNumber}</a>    
                        </c:otherwise>     
                     </c:choose>   
               </pg:pages>   
               <pg:next><a href="${pageUrl}${paramsString}">下一页</a></pg:next>   
               <pg:last><a href="${pageUrl}${paramsString}"><nobr>[尾页]</nobr></a></pg:last>   
            </pg:index>       
        </pg:pager>
        
			<span class="Right">记录总数：${pager.totalSize}  总页数：${pager.totalPageCount}</span>
		</div>
        
  </body>
</html>